package com.jjb.saas.demo.app.role.executor.query;

import com.alibaba.cola.dto.PageResponse;
import com.alibaba.cola.dto.SingleResponse;
import com.jjb.saas.demo.infrastructure.converter.RoleConvertor;
import com.jjb.saas.demo.infrastructure.persistence.domainobject.RoleDO;
import com.jjb.saas.demo.infrastructure.queryservice.RoleQueryService;
import com.jjb.saas.system.client.role.request.RolePageQry;
import com.jjb.saas.system.client.role.response.RoleCO;
import com.jjb.saas.system.client.role.response.RoleDetailCO;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Component;


/**
 * @author tzh * @date 2022年07月09日 16:39
 */
@Component
@AllArgsConstructor
public class RoleQueryExe {
    private final RoleQueryService roleQueryService;
    private final RoleConvertor convertor;
    /**
     * 查询
     * @param qry
     * @return
     */
    public PageResponse<RoleCO> execute(RolePageQry qry){
        return roleQueryService.listPage(qry);
    }

    /**
     * 详情
     * @param id
     * @return
     */
    public SingleResponse<RoleDetailCO> execute(Long id){
        RoleDO roleDO = roleQueryService.getById(id);
        RoleDetailCO roleDetailCO = convertor.convertDOToDetailCO(roleDO);
        return SingleResponse.of(roleDetailCO);
    }

}
